/**
 * 课表查询
 */

<template>
  <div class="courseBox">
    <div class="courseBoxTop">
      <!-- 搜索 -->
      <div class="courseBoxTopSearch">
        <div class="courseName">
          <span>排课名称：</span>
          <el-input
            v-model="searchForm.scheduleName"
            placeholder="请输入排课名称"
            style="max-width: 220px"
          />
        </div>
        <div class="profession">
          <span>学院：</span>
          <el-select
            v-model="searchForm.colleageId"
            placeholder="请选择所属学院"
            clearable
            @clear="infoHandleClear"
            ref="infoSelectUpResId"
          >
            <!-- // 设置一个隐藏的下拉选项
              // 如果不设置一个下拉选项，下面的树形组件将无法正常使用 -->
            <el-option
              hidden
              :value="searchForm.colleageId"
              :label="colleageName"
            >
            </el-option>
            <!-- // 设置树形组件
                是否在点击节点的时候展开或者收缩节点， 默认值为 true，如果为 false，则只有点箭头图标的时候才会展开或者收缩节点。
                // 是否在点击节点的时候选中节点，默认值为 false，即只有在点击复选框时才会选中节点。
                  // 节点被点击时的回调 -->
            <el-tree
              :data="editSeletOptions"
              :props="defaultProps"
              :expand-on-click-node="false"
              :check-on-click-node="true"
              @node-click="infoHandleNodeClick"
            >
            </el-tree>
          </el-select>
        </div>
        <div class="profession">
          <span>专业：</span>
          <el-select
            v-model="searchForm.majorId"
            placeholder="请选择所属专业"
            @change="getClassList"
          >
            <el-option
              v-for="(item, index) in majorList"
              :key="index"
              :label="item.majorName"
              :value="item.majorId"
            >
            </el-option>
          </el-select>
        </div>
        <div class="profession">
          <span>班级：</span>
          <el-select v-model="searchForm.classId" placeholder="请选择所属班级">
            <el-option
              v-for="item in classListData"
              :key="item.classId"
              :label="item.className"
              :value="item.classId"
            >
            </el-option>
          </el-select>
        </div>
        <div class="profession">
          <span>学期：</span>
          <el-select v-model="searchForm.semesterId" placeholder="请选择学期">
             <el-option
              v-for="item in schoolYearList"
              :key="item.id"
              :label="item.remarkSchool"
              :value="item.id"
            >
            </el-option>
          </el-select>
        </div>
        <div class="profession">
          <span>状态：</span>
          <el-select v-model="searchForm.status" placeholder="请选择状态">
            <el-option label="启用" value="0"> </el-option>
            <el-option label="停用" value="1"> </el-option>
          </el-select>
        </div>

        <div class="searchAndReset">
          <el-button class="searchBtn" @click="searchInput">
            <i class="el-icon-search"></i>
            <span>搜索</span>
          </el-button>
          <el-button class="resetBtn" @click="refreshInput">
            <i class="el-icon-refresh"></i>
            <span>重置</span>
          </el-button>
        </div>
      </div>
    </div>

    <!-- 管理列表 -->
    <div class="courseBoxBottom">
      <div class="bottomHeader">
        <span class="title">管理列表</span>
      </div>

      <!-- 表格 -->
      <div class="bottomMian">
        <el-table
          ref="multipleTable"
          :data="courseSchedulingList"
          tooltip-effect="dark"
          style="width: 100%"
          @selection-change="handleSelectionChange"
        >
          <el-table-column type="selection" width="50"></el-table-column>
          <el-table-column
            type="index"
            label="序号"
            width="50"
          ></el-table-column>
          <el-table-column
            prop="scheduleName"
            label="排课名称"
          ></el-table-column>
          <el-table-column prop="gradeTypeName" label="年级"></el-table-column>
          <el-table-column prop="schoolYearName" label="学年学期" width="180">
            <template slot-scope="scope">
              {{ scope.row.schoolYearName }}{{ scope.row.timeSolt }}
            </template>
          </el-table-column>
          <el-table-column prop="colleageName" label="学院"></el-table-column>
          <el-table-column prop="majorName" label="所属专业"></el-table-column>
          <el-table-column prop="className" label="班级"></el-table-column>
          <el-table-column
            prop="limitTime"
            label="截止时间"
            width="180"
          ></el-table-column>

          <el-table-column prop="action" label="操作" width="180">
            <template slot-scope="scope">
              <div class="action">
                <span class="copy" @click="courseScheduling(scope.row)">
                  查看课表
                </span>
              </div>
            </template>
          </el-table-column>
        </el-table>
      </div>

      <!-- 分页 -->
      <div class="pagination" v-if="courseSchedulingList.length > 0">
        <el-pagination
          @current-change="handleCurrentChange"
          :current-page="currentPage"
          :page-size="10"
          prev-text="上一页"
          next-text="下一页"
          layout=" prev, pager, next"
          :total="total"
        >
        </el-pagination>
        <div class="jumper">
          跳到第
          <input type="text" ref="currentPage" value="1" />
          页
        </div>
        <button class="submit" @click="goPage">确定</button>
      </div>
    </div>

    <!-- 排课 -->
    <div class="dialog1">
      <el-dialog
        title="排课"
        :visible.sync="dialogVisible"
        center
        v-loading.lock="isLoading"
        @close="closeDialogVisible"
      >
        <div class="dialogBox">
          <div class="header">
            {{ courseObj.scheduleName }}
            {{ courseObj.gradeTypeName }}
            {{ courseObj.schoolYearName }}{{ courseObj.timeSolt }}
            {{ courseObj.colleageName }}
            {{ courseObj.majorName }}
            {{ courseObj.className }}
          </div>
          <table class="mian" border="1" cellspacing="0" cellpadding="0">
            <thead class="thd">
              <tr v-for="(item, index) in weekList" :key="index" class="thd_tr">
                <th class="thd_th">
                  {{ item.title }}
                </th>
              </tr>
            </thead>
            <tbody class="tbd">
              <tr v-for="(item, index) in hourList" :key="index" class="tbd_tr">
                <td class="tbd_td tbd_title">
                  {{ item.title }}
                </td>
                <td class="time tbd_td">
                  <input
                    type="text"
                    v-model="item.timeSlots"
                    :data-id="item.id"
                    class="time tbd_td"
                  />
                </td>

                <td
                  v-for="(it, ind) in item.children"
                  :key="ind"
                  :class="it.calssName ? it.calssName + ' tbd_td' : 'tbd_td'"
                  :data-id="item.id + '-' + it.id"
                >
                  <template>{{ it.title }}</template>
                </td>
              </tr>
            </tbody>
          </table>
          <div slot="footer" class="dialog-footer">
            <el-button class="close" @click="closeDialogVisible"
              >取 消</el-button
            >
            <el-button type="primary" @click="closeDialogVisible"
              >确 定</el-button
            >
          </div>
        </div>
      </el-dialog>
    </div>
  </div>
</template>

<script>
import "@/styles/picture.scss";
import {
  getMajorListApi,
  getCourseListDetailApi,
  getCourseSchedulingListApi,
} from "@/api/educational/courseScheduling";

import {
  schoolYearItemApi,
  colleageTreeDataApi,
  getClassGradeListApi,
} from "@/api/basics/teachingPlan";


import moment from "moment";

export default {
  data() {
    return {
      isEdit: false,
      total: 0,
      courseSchedulingList: [],
      id: "",
      courseId: "",
      color: "",
      selectCourse: "",
      colleageName: "",
      multipleSelection: [],
      currentPage: 1,
      pageSize: 10,
      colorFlag: false,
      dialogFormVisible: false,
      dialogVisible: false,
      isLoading: false,
      majorList: [],
      editSeletOptions: [],
      classListData: [],
      searchForm: {
        status: "",
        scheduleId: "",
        scheduleName: "",
        colleageId: "",
        majorId: "",
        classId: "",
        semesterId: "",
      },
      form: {
        scheduleId: "",
        scheduleName: "",
        colleageId: "",
        majorId: "",
        gradeTypeId: "",
        classId: "",
        semesterId: "",
        totalLessonPeriod: "",
        weekLessonPeriod: "",
        weeks: "",
        limitTime: "",
      },
      defaultProps: {
        children: "children",
        label: "label",
      },
      formLabelWidth: "100px",
      courseSchedulingData: {},
      courseObj: {},
      hourList: [
        {
          id: "1",
          title: "早1",
          rowNum: 1,
          timeSlots: "",
          children: [
            {
              id: 0,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 1,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 2,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 3,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 4,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 5,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 6,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
          ],
        },
        {
          id: "2",
          title: "第一节",
          rowNum: 2,
          timeSlots: "",
          children: [
            {
              id: 0,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 1,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 2,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 3,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 4,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 5,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 6,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
          ],
        },
        {
          id: "3",
          title: "第二节",
          rowNum: 3,
          timeSlots: "",
          children: [
            {
              id: 0,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 1,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 2,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 3,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 4,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 5,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 6,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
          ],
        },
        {
          id: "13",
          title: "课间",
          rowNum: 4,
          timeSlots: "",
          children: [
            {
              id: 0,
              title: "",
              calssName: "disabled",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 1,
              title: "",
              calssName: "disabled",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 2,
              title: "",
              calssName: "disabled",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 3,
              title: "",
              calssName: "disabled",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 4,
              title: "",
              calssName: "disabled",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 5,
              title: "",
              calssName: "disabled",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 6,
              title: "",
              calssName: "disabled",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
          ],
        },
        {
          id: "4",
          title: "第三节",
          rowNum: 4,
          timeSlots: "",
          children: [
            {
              id: 0,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 1,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 2,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 3,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 4,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 5,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 6,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
          ],
        },
        {
          id: "5",
          title: "第四节",
          rowNum: 5,
          timeSlots: "",
          children: [
            {
              id: 0,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 1,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 2,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 3,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 4,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 5,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 6,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
          ],
        },
        {
          id: "14",
          title: "午休",
          rowNum: 5,
          timeSlots: "",
          children: [
            {
              id: 0,
              title: "",
              calssName: "disabled",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 1,
              title: "",
              calssName: "disabled",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 2,
              title: "",
              calssName: "disabled",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 3,
              title: "",
              calssName: "disabled",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 4,
              title: "",
              calssName: "disabled",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 5,
              title: "",
              calssName: "disabled",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 6,
              title: "",
              calssName: "disabled",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
          ],
        },
        {
          id: "6",
          title: "第五节",
          rowNum: 6,
          timeSlots: "",
          children: [
            {
              id: 0,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 1,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 2,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 3,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 4,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 5,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 6,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
          ],
        },
        {
          id: "7",
          title: "第六节",
          rowNum: 7,
          timeSlots: "",
          children: [
            {
              id: 0,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 1,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 2,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 3,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 4,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 5,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 6,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
          ],
        },
        {
          id: "8",
          title: "第七节",
          rowNum: 8,
          timeSlots: "",
          children: [
            {
              id: 0,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 1,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 2,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 3,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 4,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 5,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 6,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
          ],
        },
        {
          id: "9",
          title: "第八节",
          rowNum: 9,
          timeSlots: "",
          children: [
            {
              id: 0,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 1,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 2,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 3,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 4,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 5,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 6,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
          ],
        },
        {
          id: "11",
          title: "晚1",
          rowNum: 11,
          timeSlots: "",
          children: [
            {
              id: 0,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 1,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 2,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 3,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 4,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 5,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 6,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
          ],
        },
        {
          id: "12",
          title: "晚2",
          rowNum: 12,
          timeSlots: "",
          children: [
            {
              id: 0,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 1,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 2,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 3,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 4,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 5,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
            {
              id: 6,
              title: "",
              calssName: "",
              courseId: "",
              courseName: "",
              courseSchedulingId: "",
            },
          ],
        },
      ],
      weekList: [
        {
          title: "",
        },
        {
          title: "时间",
        },
        {
          title: "星期一",
        },
        {
          title: "星期二",
        },
        {
          title: "星期三",
        },
        {
          title: "星期四",
        },
        {
          title: "星期五",
        },
        {
          title: "星期六",
        },
        {
          title: "星期日",
        },
      ],
      hourList1: [],
      schoolYearList: [],
      params: {
        beginTime: "2000-01-01",
        endTime: moment(new Date()).format("YYYY-MM-DD"),
      },
    };
  },

  mounted() {
    this.hourList1 = [...this.hourList];

    // 获取排课列表
    this.getCourseSchedulingList({
      pageNum: this.currentPage,
      pageSize: this.pageSize,
    });

    // 获取学年学期
    this.getSchoolYear();

    // 获取所属专业列表
    this.getMajorList();

    // 获取班级列表
    this.getClassGradeList();

    // 获取所属学院列表
    this.editSelectTreeData();
  },

  methods: {
    // 获取学年学期
    async getSchoolYear() {
      const res = await schoolYearItemApi();
      if (res.code === 200) {
        this.schoolYearList = res.data;
      }
    },

    // 获取所属学院下拉框
    async editSelectTreeData() {
      const res = await colleageTreeDataApi();
      if (res.code === 200) {
        this.editSeletOptions = res.data;
      }
    },

    // 将选择器的值置空
    infoHandleClear() {
      this.colleageName = "";
      this.searchForm.colleageId = "";
    },

    // 弹框下拉树
    infoHandleNodeClick(data) {
      // // 这里主要配置树形组件点击节点后，设置选择器的值；自己配置的数据，仅供参考
      this.colleageName = data.label;
      this.searchForm.colleageId = data.id;
      this.getMajorList(data.id);
      // // 选择器执行完成后，使其失去焦点隐藏下拉框的效果
      this.$refs.infoSelectUpResId.blur();
    },

    // 获取所属专业列表
    async getMajorList(id) {
      if (id) {
        let res = await getMajorListApi({ colleageId: id ,});
        if (res.code === 200) {
          this.majorList = res.data;
        }
      } else {
        let res = await getMajorListApi();
        if (res.code === 200) {
          this.majorList = res.data;
        }
      }
    },

    // 获取班级列表
    async getClassGradeList(id) {
      if (id) {
        await getClassGradeListApi({ majorId: id ,pageSize:100}).then((res) => {
          this.classListData = res.rows;
        });
      } else {
        await getClassGradeListApi({pageSize:100}).then((res) => {
          this.classListData = res.rows;
        });
      }
    },

    // 选择专业 请求班级列表
    getClassList(val) {
      this.getClassGradeList(val);
    },

    // 获取排课列表
    async getCourseSchedulingList(data) {
      await getCourseSchedulingListApi({
        ...data,
        params: this.params,
        status: "0",
      }).then((res) => {
        if (res.code === 200) {
          this.total = res.total
          this.courseSchedulingList = res.rows.map((item) => {
            return {
              ...item,
              status: item.status == "0" ? true : false,
            };
          });
        }
      });
    },

    // 开启排课弹框
    courseScheduling(val) {
      this.courseObj = val;
      this.isLoading = true;
      this.courseId = val.scheduleId;
      getCourseListDetailApi({ scheduleId: val.scheduleId }).then((res) => {
        if (res.code === 200) {
          this.isLoading = false;
          if (res.data.children.length > 0) {
            let arr = res.data.children.splice(0, 3);
            arr.push({
              id: "13", // id
              title: "课间", // 一级标题
              rowNum: 4, // 排序 标识
              timeSlots: "",
              children: [
                {
                  id: "13-1", // id
                  title: "", // 标题
                  calssName: "disabled", // 类名
                  courseId: "", // 课程id
                  courseName: "", // 课程名称
                  courseSchedulingId: "", // 排课id
                },
                {
                  id: "13-2", // id
                  title: "", // 标题
                  calssName: "disabled", // 类名
                  courseId: "", // 课程id
                  courseName: "", // 课程名称
                  courseSchedulingId: "", // 排课id
                },
                {
                  id: "13-3", // id
                  title: "", // 标题
                  calssName: "disabled", // 类名
                  courseId: "", // 课程id
                  courseName: "", // 课程名称
                  courseSchedulingId: "", // 排课id
                },
                {
                  id: "13-4", // id
                  title: "", // 标题
                  calssName: "disabled", // 类名
                  courseId: "", // 课程id
                  courseName: "", // 课程名称
                  courseSchedulingId: "", // 排课id
                },
                {
                  id: "13-5", // id
                  title: "", // 标题
                  calssName: "disabled", // 类名
                  courseId: "", // 课程id
                  courseName: "", // 课程名称
                  courseSchedulingId: "", // 排课id
                },
                {
                  id: "13-6", // id
                  title: "", // 标题
                  calssName: "disabled", // 类名
                  courseId: "", // 课程id
                  courseName: "", // 课程名称
                  courseSchedulingId: "", // 排课id
                },
                {
                  id: "13-7", // id
                  title: "", // 标题
                  calssName: "disabled", // 类名
                  courseId: "", // 课程id
                  courseName: "", // 课程名称
                  courseSchedulingId: "", // 排课id
                },
              ],
            });

            let arr1 = res.data.children.splice(0, 2);
            arr1.push({
              id: "14", // id
              title: "午休", // 一级标题
              rowNum: 7, // 排序 标识
              timeSlots: "",
              children: [
                {
                  id: "14-1", // id
                  title: "", // 标题
                  calssName: "disabled", // 类名
                  courseId: "", // 课程id
                  courseName: "", // 课程名称
                  courseSchedulingId: "", // 排课id
                },
                {
                  id: "14-2", // id
                  title: "", // 标题
                  calssName: "disabled", // 类名
                  courseId: "", // 课程id
                  courseName: "", // 课程名称
                  courseSchedulingId: "", // 排课id
                },
                {
                  id: "14-3", // id
                  title: "", // 标题
                  calssName: "disabled", // 类名
                  courseId: "", // 课程id
                  courseName: "", // 课程名称
                  courseSchedulingId: "", // 排课id
                },
                {
                  id: "14-4", // id
                  title: "", // 标题
                  calssName: "disabled", // 类名
                  courseId: "", // 课程id
                  courseName: "", // 课程名称
                  courseSchedulingId: "", // 排课id
                },
                {
                  id: "14-5", // id
                  title: "", // 标题
                  calssName: "disabled", // 类名
                  courseId: "", // 课程id
                  courseName: "", // 课程名称
                  courseSchedulingId: "", // 排课id
                },
                {
                  id: "14-6", // id
                  title: "", // 标题
                  calssName: "disabled", // 类名
                  courseId: "", // 课程id
                  courseName: "", // 课程名称
                  courseSchedulingId: "", // 排课id
                },
                {
                  id: "14-7", // id
                  title: "", // 标题
                  calssName: "disabled", // 类名
                  courseId: "", // 课程id
                  courseName: "", // 课程名称
                  courseSchedulingId: "", // 排课id
                },
              ],
            });

            this.hourList = [...arr, ...arr1, ...res.data.children];
          } else {
            this.hourList = [...this.hourList1];
          }
        }
      });

      this.colorFlag = false;
      this.dialogVisible = true;
    },

    // 关闭排课弹框
    closeDialogVisible() {
      this.colorFlag = false;
      this.dialogVisible = false;
      this.hourList = [...this.hourList1];
    },

    //  搜索
    searchInput() {
      this.getCourseSchedulingList({
        pageNum: this.currentPage,
        pageSize: this.pageSize,
        ...this.searchForm,
      });
    },

    // 重置
    refreshInput() {
      this.searchForm = {
        status: "",
        scheduleId: "",
        scheduleName: "",
        colleageId: "",
        majorId: "",
        classId: "",
        semesterId: "",
      };
      this.colleageName = "";

      this.getCourseSchedulingList({
        pageNum: this.currentPage,
        pageSize: this.pageSize,
      });

      // 获取学年学期
      this.getSchoolYear();

      // 获取所属专业列表
      this.getMajorList();

      // 获取班级列表
      this.getClassGradeList();

      // 获取所属学院列表
      this.editSelectTreeData();
    },

    // 已选中
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },

    // 设置当前页码
    handleCurrentChange(val) {
      this.currentPage = val;
      // 获取排课列表
      this.getCourseSchedulingList({
        pageNum: this.currentPage,
        pageSize: this.pageSize,
      });
    },

    // 跳转当前页
    goPage() {
      let { value } = this.$refs.currentPage;
      this.currentPage = Number(value);
      // 获取排课列表
      this.getCourseSchedulingList({
        pageNum: this.currentPage,
        pageSize: this.pageSize,
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.courseBox {
  position: relative;
  box-sizing: border-box;

  .checkStudentStatus {
    width: 100%;
    height: 100%;
    position: absolute;
    z-index: 9;
    top: 0;
    background-color: #f3f2f7;
    padding: 20px 0 0 0;
    box-sizing: border-box;
  }

  .courseBoxTop {
    .courseBoxTopSearch {
      display: flex;
      flex-wrap: wrap;
      justify-content: flex-start;

      .courseName {
        span {
          width: 146px;
        }
      }

      .profession {
        span {
          width: 130px;
        }
      }

      .searchAndReset {
        flex: 1;
        justify-content: end;
      }

      ::v-deep .el-input__inner {
        height: 36px;
        line-height: 36px;
      }
    }
  }
}

.courseScheduling {
  margin-left: 6px;
  color: #4b93d5;
  cursor: pointer;
}

.action {
  display: flex;
  align-items: center;
  justify-content: center;

  .copy {
    margin-left: 6px;
    color: #4b93d5;
    cursor: pointer;
  }
}

::v-deep .el-icon-date {
  line-height: 36px;
}

.dialog {
  .block {
    width: 280px;
    height: 30px;
    border: solid 1px #dcdfe6;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-sizing: border-box;
    background-color: #fff;

    ::v-deep .el-input__inner {
      width: 240px;
      height: 28px;
      border: none;
    }

    ::v-deep .el-icon-arrow-down {
      color: #c2c2c2;
      padding: 0 10px 0 0;
    }

    ::v-deep .el-icon-arrow-up {
      color: #c2c2c2;
      padding: 0 10px 0 0;
    }

    ::v-deep .el-date-picker.has-sidebar {
      left: 460px !important;
      background-color: #4895db;
    }
  }

  ::v-deep .el-dialog {
    max-width: 750px;
    min-width: 500px;
    border-radius: 10px;
    background-color: #f9f9f9;
  }

  ::v-deep .el-dialog__header {
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    background-color: #4895db;
    padding: 0;
    border-radius: 10px 10px 0 0;

    span {
      font-size: 16px;
      color: #fff;
    }
  }

  ::v-deep .el-dialog__headerbtn {
    top: 15px;
  }

  ::v-deep .el-dialog__headerbtn .el-dialog__close {
    color: #fff;
    font-size: 18px;
  }

  ::v-deep .el-dialog--center .el-dialog__body {
    text-align: initial;
    display: flex;
    justify-content: center;
  }

  ::v-deep .el-input__inner {
    height: 30px;
    line-height: 30px;
  }

  ::v-deep .el-form-item__content {
    width: 300px;
  }

  ::v-deep .el-form-item {
    margin-bottom: 10px;
  }

  ::v-deep .el-dialog__footer {
    padding: 10px 20px 50px;
  }

  ::v-deep .el-button--default {
    width: 130px;
    border-radius: 20px;
    background-color: #fff;
    color: #4b95d6;
    border: solid 1px #4b95d6;
  }

  ::v-deep .el-button + .el-button {
    width: 130px;
    border-radius: 20px;
    margin-left: 50px;
    background-color: #4895db;
    border-color: #4895db;
  }
}

.dialog1 {
  ::v-deep .el-dialog {
    min-width: 1100px;
    border-radius: 10px;
    background-color: #f9f9f9;
  }

  ::v-deep .el-dialog__header {
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    background-color: #4895db;
    padding: 0;
    border-radius: 10px 10px 0 0;

    span {
      font-size: 16px;
      color: #fff;
    }
  }

  ::v-deep .el-dialog__headerbtn {
    top: 15px;
  }

  ::v-deep .el-dialog__headerbtn .el-dialog__close {
    color: #fff;
    font-size: 18px;
  }
}

.dialogBox {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;

  .mian {
    margin: 30px 0;

    .thd {
      display: flex;

      .thd_tr {
        .thd_th {
          width: 100px;
          height: 32px;
          display: flex;
          align-items: center;
          justify-content: center;
        }
      }
    }

    .tbd {
      display: flex;
      flex-direction: column;

      .tbd_tr {
        display: flex;

        .tbd_td {
          width: 100px;
          height: 32px;
          display: flex;
          align-items: center;
          justify-content: center;
          input {
            width: 100%;
            height: 100%;
            background-color: transparent;
            border: none;
            outline: none;
            text-align: center;
          }
        }

        .green {
          background-color: #a2ef4d;
          color: #fff;
        }

        .blue {
          background-color: #4095e5;
          color: #fff;
        }

        .yellow {
          background-color: #fcca00;
          color: #fff;
        }

        .red {
          background-color: #e01e0d;
          color: #fff;
        }

        .disabled {
          background-color: #9a9a9a;
        }
      }
    }
  }

  .dialog-footer {
    text-align: center;
  }
}
</style>